package com.jarveis.frame.zbus.rpc;

import java.io.IOException;

import org.zbus.broker.Broker;
import org.zbus.broker.ZbusBroker;
import org.zbus.net.http.Message.MessageInvoker;
import org.zbus.rpc.RpcCodec.Request;
import org.zbus.rpc.RpcCodec.Response;
import org.zbus.rpc.RpcInvoker;
import org.zbus.rpc.mq.MqInvoker;

public class RpcClient {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		Broker broker = new ZbusBroker("127.0.0.1:15555"); 
		MessageInvoker mqInvoker = new MqInvoker(broker, "MyRpc");  
		 
		RpcInvoker rpc = new RpcInvoker(mqInvoker); 
		  
		Request request = new Request(); 
		request.setMethod("echo");
		request.setParams(new Object[]{"Hello World!"});
		
		Response response = rpc.invokeSync(request);
		System.out.println(response.getResult()); 
		
		broker.close();
	}

}
